using System;
using System.Collections.Generic;

namespace WCFServer.BusinessLogic
{
    /// <summary>
    /// Data Contract Class - Karta
    /// </summary>
    public partial class Card
    {
        private color kolorField;

        public color kolor
        {
            get { return kolorField; }
            set { kolorField = value; }
        }

        private CardFace wartoscField;

        public CardFace wartosc
        {
            get { return wartoscField; }
            set { wartoscField = value; }
        }

        public enum color
        {
            Clubs,
            Diamonds,
            Hearts,
            Spades
        }

        public enum CardFace
        {
            two,
            three,
            four,
            five,
            six,
            seven,
            eight,
            nine,
            ten,
            jack,
            queen,
            king,
            ace
        }

    }

    public class CardComparer : IComparer<Card>
    {

        #region IComparer<Card> Members

        public int Compare(Card x, Card y)
        {
            if (x == null)
            {
                if (y == null)
                    return 0;               
                else
                    return -1;
            }
            else
            {
                if (y == null)
                    return 1;
                else
                {
                    return CardToInt(x) - CardToInt(y);
                }
            }
        }

        private int CardToInt(Card c)
        {
            switch (c.wartosc)
            {
                    case Card.CardFace.ace:
                    {
                        return 14;
                    }
                case Card.CardFace.king:
                    {
                        return 13;
                    }
                case Card.CardFace.queen:
                    {
                        return 12;
                    }
                case Card.CardFace.jack:
                    {
                        return 11;
                    }
                case Card.CardFace.ten:
                    {
                        return 10;
                    }
                case Card.CardFace.nine:
                    {
                        return 9;
                    }
                case Card.CardFace.eight:
                    {
                        return 8;
                    }
                case Card.CardFace.seven:
                    {
                        return 7;
                    }
                case Card.CardFace.six:
                    {
                        return 6;
                    }
                case Card.CardFace.five:
                    {
                        return 5;
                    }
                case Card.CardFace.four:
                    {
                        return 4;
                    }
                case Card.CardFace.three:
                    {
                        return 3;
                    }
                case Card.CardFace.two:
                    {
                        return 2;
                    }
                default:
                    {
                        return 0;
                    }
            }
        }

        #endregion
    }
}
